// See https://sequelize.org/master/manual/model-basics.html
// for more of what you can do here.
import { Sequelize, DataTypes, Model } from 'sequelize';
import { Application } from '../declarations';
import { HookReturn } from 'sequelize/types/hooks';

export default function (app: Application): typeof Model {
  const sequelizeClient: Sequelize = app.get('sequelizeClient');
  const keepgrain = sequelizeClient.define('keepgrain', {
    // 编号
    num:{
      type:DataTypes.INTEGER,
      allowNull: false,
      unique: true
    },
    // 产品名称   
    proName:{
      type:DataTypes.STRING,
      allowNull:false
    },
    // 公司名   
    companyName:{
      type:DataTypes.STRING,
      allowNull:false
    },
    // 产品类别  
    proClass:{
      type:DataTypes.STRING,
      allowNull:false
    
    },
    // 采购人   
    purchaser:{
      type:DataTypes.STRING,
      allowNull:false
    },
    // 责任人  
    liable:{
      type:DataTypes.STRING,
      allowNull:false
    },
    
    // 当前数量 
    nowNum:{
      type:DataTypes.INTEGER,
      allowNull:false
    },
    

  }, {
    hooks: {
      beforeCount(options: any): HookReturn {
        options.raw = true;
      }
    }
  });

  // eslint-disable-next-line @typescript-eslint/no-unused-vars
  (keepgrain as any).associate = function (models: any): void {
    // Define associations here
    // See https://sequelize.org/master/manual/assocs.html
  };

  return keepgrain;
}
